package com.bball.court.http;

import android.content.Context;
import android.util.Log;

import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.bball.court.http.base.GsonGetRequest;
import com.bball.court.model.CourtList;

public class GetClosestCourtRequest<T extends CourtList> extends GsonGetRequest<T> {

    public GetClosestCourtRequest(Context context, String url, Class<T> clazz, String tag,  final GetCourtsRequestCallbacks callbacks) {
        super(context, url, clazz, tag, new Listener<T>() {
            @Override
            public void onResponse(T courts) {
                callbacks.onGetCourtsRequestComplete(courts);
            }
        }, new ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(getClass().getSimpleName(), error.getMessage(), error);
                callbacks.onGetCourtsRequestFailed(new RuntimeException(error));
            }
        });
    }
}
